package com.learn.proxy.javassit.base;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.swing.DesktopUtil;
import com.skill.test.ValidHolder;
import lombok.Getter;
import org.junit.jupiter.api.AfterEach;

import java.io.File;

public abstract class Base
    extends ValidHolder
{
    @Getter
    private final String directory = "E:/tmp/javassit";

    protected boolean open() {
        return false;
    }

    @AfterEach
    void tearDown() throws Exception {
        String classDirectory = this.getClass().getPackage().getName().replaceAll("\\.", "/");
        String openDirectory = getDirectory() + FileUtil.FILE_SEPARATOR + classDirectory;
        if (FileUtil.exist(openDirectory) && open()) {
            DesktopUtil.open(new File(openDirectory));
        }
    }
}
